import {HttpRequest} from "@/network";
import {ApiConst} from "@/network/config/ApiConst";
import AppConfig from "@/config/AppConfig";

let env = AppConfig.env;
export default class CouponService {

  static async getWxCoupon() {
    let promise = HttpRequest.get({
      url: ApiConst.coupon[env].get.GET_WX_COUPON,
      env: env,
    }).then(res => {
      if (res.err === null) {
        return res.data.data
      }
    }).catch(err => {
      console.error("请求出错。");
      throw err;
    })
    return await promise;
  }

  static async getWxCoupon2() {
    let promise = HttpRequest.get({
      url: ApiConst.coupon[env].get.GET_WX_COUPON_2,
      env: env,
    }).then(res => {
      if (res.err === null) {
        return res.data.data
      }
    }).catch(err => {
      console.error("请求出错。");
      throw err;
    })
    return await promise;
  }

  static async getShopCoupon() {
    let promise = HttpRequest.get({
      url: ApiConst.coupon[env].get.GET_SHOP_COUPON,
      env: env,
    }).then(res => {
      if (res.err === null) {
        return res.data.data
      }
    }).catch(err => {
      console.error("请求出错。");
      throw err;
    })
    return await promise;
  }
}

